#ifndef PLAYER_H_
#define PLAYER_H_

#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "player.h"
#include "socket.h"
#include "link.h"
#include <sys/wait.h>
#include <sys/types.h>
#include <unistd.h>

//定义播放模式	
#define SEQUENCE	1		//顺序播放
#define CIRCLE		2		//单曲循环

#define SHMKEY		1234		//或者通过key_t key = ftok("/tmp", 'A');获取key值
#define SHMSIZE		4096		//内存创建以页为单位，1页等于4kb即4096字节

#define URL			"http://119.29.200.94/music/"

//共享内存存放的数据
typedef struct Shm
{
	pid_t parent_pid;		//父进程的PID
	pid_t child_pid;		//子进程的PID
	pid_t grand_pid;		//孙进程的PID
	char cur_music[128];	//当前播放的音乐名字	小小虫.mp3
	int mode;				//播放模式
}Shm;

int init_shm(void);
int get_shm(Shm *s);
int get_volume(int *v);
void get_music(const char *singer);
int start_play();
void play_music(char *n);
void child_process(char *n);
void grand_set_shm(Shm s);
void grand_get_shm(Shm *s);
void stop_play();
void write_fifo(const char *cmd);
void suspend_play();
void continue_play();
void next_play();
int get_shm(Shm *s);
void prior_play();
void voice_up();
void voice_down();
void circle_play();
void sequence_play();
void singer_play(const char *singer);

#endif
